
/*globalization & conflict*/
clear
set more off
set matsize 800
cd "C:\Users\amel\Documents\Civil War Article"
log using invcon2.txt, t replace

use cwout
mi import flong, m(imp) id(year ccode) imp(warl-pcprod)
mi describe
mi register regular ccode cname year nwstate
mi varying
drop imp

mi xtset ccode year

mi xeq: sort ccode year; by ccode: gen polity2l=L.polity2
replace polity2l=polity2 if missing(polity2l)
gen linternet=ln(internet+1)
mi xeq: sort ccode year; by ccode: gen linternetl=L.linternet
replace linternetl=linternet if missing(linternetl)
mi xeq: sort ccode year; by ccode: gen kaopenl=L.kaopen
replace kaopenl=kaopen if missing(kaopenl)
gen lfdistock2=ln(fdistock2+1)
gen lfpistockgdp=ln(fpistockgdp+1)
mi xeq: sort ccode year; by ccode: gen lfdistock2l=L.lfdistock2
replace lfdistock2l=lfdistock2 if missing(lfdistock2l)
gen totalfdistock=fdistock2*gdppc*pop
gen ltotalfdistock=ln(totalfdistock+1)
mi xeq: sort ccode year; by ccode: gen ltotalfdistockl=L.ltotalfdistock
replace ltotalfdistockl=ltotalfdistock if missing(ltotalfdistockl)
mi xeq: sort ccode year; by ccode: gen lfpistockgdpl=L.lfpistockgdp
replace lfpistockgdpl=lfpistockgdp if missing(lfpistockgdpl)
mi xeq: sort ccode year; by ccode: gen gdppcl=L.gdppc
replace gdppcl=gdppc if missing(gdppcl)
gen lgdppc=ln(gdppc)
mi xeq: sort ccode year; by ccode: gen lgdppcl=L.lgdppc
replace lgdppcl=lgdppc if missing(lgdppcl)
gen lpop=ln(pop)
mi xeq: sort ccode year; by ccode: gen lpopl=L.lpop
replace lpopl=lpop if missing(lpopl)
gen totalgdp=gdppc*pop
gen ltotalgdp=ln(totalgdp)
mi xeq: sort ccode year; by ccode: gen ltotalgdpl=L.ltotalgdp
replace ltotalgdpl=ltotalgdp if missing(ltotalgdpl)
gen dopen=kaopen-kaopenl
mi xeq: sort ccode year; by ccode: gen dopenl=L.dopen
replace dopenl=dopen if missing(dopenl)
mi xeq: sort ccode year; by ccode: gen yearl=L.year
replace yearl=year-1 if missing(yearl)
mi xeq: sort ccode year; by ccode: gen growth=(gdppc-L.gdppc)/L.gdppc
gen lgrowth=.
replace lgrowth=ln(growth) if growth>0
replace lgrowth=-ln(-growth+1) if growth<=0
mi xeq: sort ccode year; by ccode: gen lgrowthl=L.lgrowth
replace lgrowthl=lgrowth if missing(lgrowthl)
replace lgrowthl=0 if missing(lgrowthl) & _mi_m~=0
mi xeq: sort ccode year; by ccode: gen tradel=L.trade
replace tradel=trade if missing(tradel)
gen ltrade=ln(trade)
mi xeq: sort ccode year; by ccode: gen ltradel=L.ltrade
replace ltradel=ltrade if missing(ltradel)
gen totaltrade=trade*gdppc*pop
gen ltotaltrade=ln(totaltrade)
mi xeq: sort ccode year; by ccode: gen ltotaltradel=L.ltotaltrade
replace ltotaltradel=ltotaltrade if missing(ltotaltradel)
mi xeq: sort ccode year; by ccode: gen oill=L.oil
replace oill=oil if missing(oill)
mi xeq: sort ccode year; by ccode: gen interrel=L.interreg
replace interrel=interreg if missing(interrel)
mi xeq: sort ccode year; by ccode: gen instabl=L.instab
replace instabl=instab if missing(instabl)
mi xeq: sort ccode year; by ccode: gen sovdoml=L.sovdom
replace sovdoml=sovdom if missing(sovdoml)
mi xeq: sort ccode year; by ccode: gen govl=L.govonly
replace govl=govonly if missing(govl)
mi xeq: sort ccode year; by ccode: gen terrl=L.terronly
replace terrl=terronly if missing(terrl)
mi xeq: sort ccode year; by ccode: gen bothl=L.bothgovterr
replace bothl=bothgovterr if missing(bothl)
gen lpcprod=ln(pcprod+1)
mi xeq: sort ccode year; by ccode: gen lpcprodl=L.lpcprod
replace lpcprodl=lpcprod if missing(lpcprodl)
mi xeq: sort ccode year; by ccode: gen war=F.warl
replace war=1 if war>0.5 & war<.
replace war=0 if war<0.5
gen mac=0
mi xeq: sort ccode year; by ccode: replace mac=1 if F.govl>0.5 & F.govl<.
mi xeq: sort ccode year; by ccode: replace mac=1 if F.terrl>0.5 & F.terrl<.
mi xeq: sort ccode year; by ccode: replace mac=1 if F.bothl>0.5 & F.bothl<.
mi xeq: sort ccode year; by ccode: replace mac=. if missing(F.bothl)
gen tonset=.
mi xeq: sort ccode year; by ccode: replace tonset=0 if missing(L.onset)
mi xeq: sort ccode year; by ccode: replace tonset=0 if L.onset==1
mi xeq: sort ccode year; by ccode: replace tonset=L.tonset+1 if missing(tonset)
replace tonset=. if missing(onset)
gen tonsetsq=tonset^2
gen tonsetcu=tonset^3
gen tnewconf=.
mi xeq: sort ccode year; by ccode: replace tnewconf=0 if missing(L.newconf)
mi xeq: sort ccode year; by ccode: replace tnewconf=0 if L.newconf==1
mi xeq: sort ccode year; by ccode: replace tnewconf=L.tnewconf+1 if missing(tnewconf)
replace tnewconf=. if missing(newconf)
gen tnewconfsq=tnewconf^2
gen tnewconfcu=tnewconf^3
gen tonset5=.
mi xeq: sort ccode year; by ccode: replace tonset5=0 if missing(L.onset5)
mi xeq: sort ccode year; by ccode: replace tonset5=0 if L.onset5==1
mi xeq: sort ccode year; by ccode: replace tonset5=L.tonset5+1 if missing(tonset5)
replace tonset5=. if missing(tonset5)
gen tonset5sq=tonset5^2
gen tonset5cu=tonset5^3
mi register passive totaltrade ltotaltrade ltotaltradel tonset tnewconf tonset5 tonsetsq tnewconfsq tonset5sq tonsetcu tnewconfcu tonset5cu lgdppcl lpopl polity2l oill ltradel lfdistock2l lfpistockgdpl interrel instabl lgrowthl ltotalgdpl ltotalfdistockl linternetl kaopenl lpcprodl govl terrl bothl dopen dopenl gdppcl growth lfdistock2 lfpistockgdp lgdppc lgrowth linternet lpcprod lpop ltotalfdistock ltotalgdp ltrade totalfdistock totalgdp tradel mac war
mi register regular yearl sovdoml 
mi describe
mi varying
sum tonset tnewconf tonset5 tonsetsq tnewconfsq tonset5sq tonsetcu tnewconfcu tonset5cu
bysort ccode year: egen meangdp=mean(gdppc)
sum meangdp
gen ldc=0
replace ldc=1 if meangdp<10239

sum nwstate sovdoml lgdppcl lpopl lmtnest polity2l oill ethfrac relfrac ltradel lfdistock2l lfpistockgdpl interrel instabl lgrowthl ltotalgdpl ltotalfdistockl ncontig linternetl kaopenl lpcprodl govl terrl bothl if _mi_m~=0 & year>1969 & occupied==0 & year<2011
mi est: mean nwstate sovdoml lgdppcl lpopl lmtnest polity2l oill ethfrac relfrac ltradel lfdistock2l lfpistockgdpl interrel instabl lgrowthl ltotalgdpl ltotalfdistockl ncontig linternetl kaopenl lpcprodl govl terrl bothl if year>1969 & occupied==0 & year<2011
corr nwstate sovdoml lgdppcl lpopl lmtnest polity2l oill ethfrac relfrac ltradel lfdistock2l lfpistockgdpl interrel instabl lgrowthl ltotalgdpl ltotalfdistockl ncontig linternetl kaopenl lpcprodl govl terrl bothl if _mi_m~=0 & year>1969 & occupied==0 & year<2011

egen gdp_s=std(lgdppcl)
egen pop_s=std(lpopl)
egen mtn_s=std(lmtnest)
egen dem_s=std(polity2l)
gen demsq=dem_s^2
egen ef_s=std(ethfrac)
egen rf_s=std(relfrac)
egen trade_s=std(ltradel)
egen fdi_s=std(lfdistock2l)
egen fpi_s=std(lfpistockgdpl)
egen res_s=std(lpcprodl)
egen grow_s=std(lgrowthl)
egen tgdp_s=std(ltotalgdpl)
egen tfdi_s=std(ltotalfdistockl)
egen ttrade_s=std(ltotaltradel)
egen dopen_s=std(dopenl)

mi register passive gdp_s pop_s mtn_s dem_s demsq ef_s rf_s trade_s fdi_s fpi_s res_s grow_s tgdp_s tfdi_s ttrade_s dopen_s
mi describe
mi varying


/*conflict onset*/
mi xeq: sort ccode year; by ccode: drop if nwstate==0 & F.nwstate==1
mi xeq: sort ccode year; by ccode: drop if nwstate==0 & F.nwstate==1
/*civil war onset*/
/*table 3, column 13; table 1, columns 1 & 4; table 2, columns 7 & 10; table 5, column 22; & sensitivity tests*/
mi est: probit onset gdp_s pop_s mtn_s nwstate ncontig oill warl yearl tonset tonsetsq tonsetcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s 
mi est: probit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel warl yearl tonset tonsetsq tonsetcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s 
mi est: probit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel warl yearl tonset tonsetsq tonsetcu trade_s fdi_s if year>1969 & occupied==0 & year<2011 & ldc==1, cluster(ccode)
mi test trade_s fdi_s 
mi est: probit onset gdp_s pop_s mtn_s ncontig oill dem_s demsq instabl ef_s rf_s interrel warl yearl tonset tonsetsq tonsetcu trade_s fdi_s if brsampl==1, cluster(ccode)
mi test trade_s fdi_s 
/*note: nwstate perfectly predicts absence of onset*/
mi est: probit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel warl yearl tonset tonsetsq tonsetcu trade_s fdi_s fpi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s fpi_s
mi est: probit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel warl yearl tonset tonsetsq tonsetcu trade_s fdi_s fpi_s if year>1969 & occupied==0 & year<2011 & ldc==1, cluster(ccode)
mi test trade_s fdi_s fpi_s
mi est: probit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel grow_s warl yearl tonset tonsetsq tonsetcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s
mi est: probit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel res_s warl yearl tonset tonsetsq tonsetcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s
mi est: probit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel dopen_s warl yearl tonset tonsetsq tonsetcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s
mi est: probit onset tgdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq ef_s rf_s warl yearl tonset tonsetsq tonsetcu ttrade_s tfdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test ttrade_s tfdi_s

/*
/*random effects*/
mi est: xtprobit onset gdp_s pop_s mtn_s nwstate ncontig oill warl yearl tonset tonsetsq tonsetcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, vce(cl ccode)
mi test trade_s fdi_s 
mi est: xtprobit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel warl yearl tonset tonsetsq tonsetcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, vce(cl ccode)
mi test trade_s fdi_s
mi est: xtprobit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel res_s warl yearl tonset tonsetsq tonsetcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, vce(cl ccode)
mi test trade_s fdi_s
*/
/*IV - table 4, columns 19 & 16*/
mi est, cmdok saving(m1, replace): ivprobit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel warl yearl tonset tonsetsq tonsetcu trade_s fdi_s (fpi_s = linternetl kaopenl ) if year>1969 & occupied==0 & year<2011, first twostep 
mi test tonset tonsetsq tonsetcu
mi test trade_s fdi_s fpi_s
mi predict xb1 using m1, xb
mi xeq: generate p1=normal(xb1)
tab onset, summarize(p1)
drop xb1 p1

/*overid test*/
mi est: probit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel warl yearl tonset tonsetsq tonsetcu trade_s fdi_s fpi_s linternetl kaopenl if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test linternetl kaopenl
/*Stock-Yogo test*/
mi est: regress fpi_s gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel warl yearl tonset tonsetsq tonsetcu trade_s fdi_s linternetl kaopenl if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test linternetl kaopenl

mi est, cmdok: ivprobit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel warl tonset tonsetsq tonsetcu trade_s (fdi_s = linternetl kaopenl ), first twostep
mi test tonset tonsetsq tonsetcu
mi test trade_s fdi_s
/*overid test*/
mi est: probit onset gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel warl tonset tonsetsq tonsetcu trade_s fdi_s linternetl kaopenl
mi test linternetl kaopenl
/*Stock-Yogo test*/
mi est: regress fdi_s gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel warl yearl tonset tonsetsq tonsetcu trade_s linternetl kaopenl if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test linternetl kaopenl

/*minor armed conflict - new incompatibility onset*/
/*simple models - table 3, column 15; table 1, columns 3 & 6; table 2, columns 9 & 12; table 5, column 24; & sensitivity tests*/
mi est: probit newconf gdp_s pop_s mtn_s nwstate ncontig oill govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s 
mi est: probit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s 
mi est: probit newconf gdp_s pop_s mtn_s ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s if brsampl==1, cluster(ccode)
mi test trade_s fdi_s 
mi est: probit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s if year>1969 & occupied==0 & year<2011 & ldc==1, cluster(ccode)
mi test trade_s fdi_s 
mi est: probit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s fpi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s fpi_s
mi est: probit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s fpi_s if year>1969 & occupied==0 & year<2011 & ldc==1, cluster(ccode)
mi test trade_s fdi_s fpi_s
mi est: probit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel grow_s govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s
mi est: probit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel res_s govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s
mi est: probit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel dopen_s govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s
mi est: probit newconf tgdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq ef_s rf_s govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu ttrade_s tfdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test ttrade_s tfdi_s
/*
/*random effects*/
mi est: xtprobit newconf gdp_s pop_s mtn_s nwstate ncontig oill govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, vce(cl ccode)
mi test trade_s fdi_s 
mi est: xtprobit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, vce(cl ccode)
mi test trade_s fdi_s
mi est: xtprobit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel res_s govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s if year>1969 & occupied==0 & year<2011, vce(cl ccode)
mi test trade_s fdi_s
*/
/*IV - table 4, columns 21 & 18*/
mi est, cmdok saving(m1, replace): ivprobit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s (fpi_s = linternetl kaopenl ) if year>1969 & occupied==0 & year<2011, first twostep 
mi test tnewconf tnewconfsq tnewconfcu
mi test trade_s fdi_s fpi_s
mi predict xb1 using m1, xb
mi xeq: generate p1=normal(xb1)
tab onset, summarize(p1)
drop xb1 p1

/*overid test*/
mi est: probit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tnewconf tnewconfsq tnewconfcu trade_s fdi_s fpi_s linternetl kaopenl if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test linternetl kaopenl

mi est, cmdok: ivprobit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl tnewconf tnewconfsq tnewconfcu trade_s (fdi_s = linternetl kaopenl ), first twostep
mi test tnewconf tnewconfsq tnewconfcu
mi test trade_s fdi_s
/*overid test*/
mi est: probit newconf gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl tnewconf tnewconfsq tnewconfcu trade_s fdi_s linternetl kaopenl
mi test linternetl kaopenl

/*minor armed conflict - 5-year window onset*/
/* table 3, column 14; table 1, columns 2 & 5; table 2, columns 8 & 11; table 5, column 23; & sensitivity tests*/
mi est: probit onset5 gdp_s pop_s mtn_s nwstate ncontig oill govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s 
mi est: probit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s 
mi est: probit onset5 gdp_s pop_s mtn_s ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s if brsampl==1, cluster(ccode)
mi test trade_s fdi_s 
mi est: probit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s if year>1969 & occupied==0 & year<2011 & ldc==1, cluster(ccode)
mi test trade_s fdi_s 
mi est: probit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s fpi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s fpi_s
mi est: probit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s fpi_s if year>1969 & occupied==0 & year<2011 & ldc==1, cluster(ccode)
mi test trade_s fdi_s fpi_s
mi est: probit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel grow_s govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s
mi est: probit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel res_s govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s
mi est: probit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel dopen_s govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test trade_s fdi_s
mi est: probit onset5 tgdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq ef_s rf_s govl terrl bothl yearl tonset5 tonset5sq tonset5cu ttrade_s tfdi_s if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test ttrade_s tfdi_s
/*
/*random effects*/
mi est: xtprobit onset5 gdp_s pop_s mtn_s nwstate ncontig oill govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s if year>1969 & occupied==0 & year<2011, vce(cl ccode)
mi test trade_s fdi_s 
mi est: xtprobit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s if year>1969 & occupied==0 & year<2011, vce(cl ccode)
mi test trade_s fdi_s
mi est: xtprobit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel res_s govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s if year>1969 & occupied==0 & year<2011, vce(cl ccode)
mi test trade_s fdi_s
*/
/*IV - table 4, columns 17 & 20*/
mi est, cmdok saving(m1, replace): ivprobit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s (fpi_s = linternetl kaopenl ) if year>1969 & occupied==0 & year<2011, first twostep 
mi test tonset5 tonset5sq tonset5cu
mi test trade_s fdi_s fpi_s
mi predict xb1 using m1, xb
mi xeq: generate p1=normal(xb1)
tab onset, summarize(p1)
drop xb1 p1

/*overid test*/
mi est: probit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl yearl tonset5 tonset5sq tonset5cu trade_s fdi_s fpi_s linternetl kaopenl if year>1969 & occupied==0 & year<2011, cluster(ccode)
mi test linternetl kaopenl

mi est, cmdok: ivprobit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl tonset5 tonset5sq tonset5cu trade_s (fdi_s = linternetl kaopenl ), first twostep
mi test tonset5 tonset5sq tonset5cu
mi test trade_s fdi_s
/*overid test*/
mi est: probit onset5 gdp_s pop_s mtn_s nwstate ncontig oill dem_s demsq instabl ef_s rf_s interrel govl terrl bothl tonset5 tonset5sq tonset5cu trade_s fdi_s linternetl kaopenl
mi test linternetl kaopenl

log close
